# -*- coding:utf-8 -*-

from PySide.QtGui import *
from PySide.QtCore import *

import sys

class GeometryDialog(QDialog):
    def __init__(self,parent=None):
        super(GeometryDialog,self).__init__(parent)

        xNameLabel=QLabel("x0:")
        yNameLabel=QLabel("y0:")
        frameGeoNameLabel=QLabel("frameGeometry():")
        posNameLabel=QLabel("pos():")
        geoNameLabel=QLabel("geometry():")
        widthNameLabel = QLabel("width():")
        heightNameLabel = QLabel("height():")
        rectNameLabel = QLabel("rect():")
        sizeNameLabel = QLabel("size():")

        self.xLabel=QLabel()
        self.yLabel = QLabel()
        self.frameGeoLabel = QLabel()
        self.posLabel = QLabel()
        self.geoLabel = QLabel()
        self.widthLabel = QLabel()
        self.heightLabel = QLabel()
        self.rectLabel = QLabel()
        self.sizeLabel = QLabel()

        layout=QGridLayout()
        layout.addWidget(xNameLabel,0,0)
        layout.addWidget(self.xLabel,0,1)
        layout.addWidget(yNameLabel,1,0)
        layout.addWidget(self.yLabel,1,1)
        layout.addWidget(frameGeoNameLabel,2,0)
        layout.addWidget(self.frameGeoLabel,2,1)
        layout.addWidget(posNameLabel,3,0)
        layout.addWidget(self.posLabel,3,1)
        layout.addWidget(geoNameLabel,4,0)
        layout.addWidget(self.geoLabel,4,1)
        layout.addWidget(widthNameLabel,5,0)
        layout.addWidget(self.widthLabel,5,1)
        layout.addWidget(heightNameLabel,6,0)
        layout.addWidget(self.heightLabel,6,1)
        layout.addWidget(rectNameLabel,7,0)
        layout.addWidget(self.rectLabel,7,1)
        layout.addWidget(sizeNameLabel,8,0)
        layout.addWidget(self.sizeLabel,8,1)

        self.setLayout(layout)
        self.updateLabelStatus()

    def moveEvent(self, event):
        self.updateLabelStatus()

    def resizeEvent(self, event):
        self.updateLabelStatus()

    def updateLabelStatus(self):
        
        self.xLabel.setText(str(self.x()))
        self.yLabel.setText(str(self.y()))

        self.frameGeoLabel.setText("("+str(self.frameGeometry().x())+","
                                   +str(self.frameGeometry().y())+","
                                   +str(self.frameGeometry().width())+","
                                   +str(self.frameGeometry().height())+")")

        self.posLabel.setText("("+str(self.pos().x())+","+str(self.pos().y())+")")

        self.geoLabel.setText("(" + str(self.geometry().x()) + ","
                                   + str(self.geometry().y()) + ","
                                   + str(self.geometry().width()) + ","
                                   + str(self.geometry().height()) + ")")
        self.widthLabel.setText(str(self.width()))
        self.heightLabel.setText(str(self.height()))

        self.rectLabel.setText("(" + str(self.rect().x()) + ","
                                   + str(self.rect().y()) + ","
                                   + str(self.rect().width()) + ","
                                   + str(self.rect().height()) + ")")

        self.sizeLabel.setText("("+str(self.size().width())+","
                               +str(self.size().height())+")")

if __name__ == "__main__":
    app = QApplication(sys.argv)
    geometryDailog=GeometryDialog()
    geometryDailog.show()
    sys.exit(app.exec_())


